import { Card, TestCard } from "../card/Card";
import { Process } from "../scene";
import { Ws } from "../ws";

export class Player {

    /**
     * 定义一个webSocket工具用来交互客户端
     */
    public ws: Ws;

    public id: string = "";

    public name: string = "";

    public cards: Array<Card> = [];

    constructor(id: string, name: string){

        this.id = id;

        this.name = name;

        // 初始化客户端交互工具
        this.ws = new Ws();

        // 加载卡组
        for( var i = 0; i < 20; i++)
            this.cards.push(new TestCard())

    }

    sendProcess (process: Process){
        console.log("-------", this.name)
        return this.ws.send(process);
    }

    // 选择card
    selectCard (){

    }

    // 主要回合选择等待抽卡
    selectCardAll (){
        return this.sendProcess({
            text: "等待用户选择",
            user: this,
        })
    }

    // 加载卡组信息
    loadCard (){
        console.log("加载卡组信息", this.name);
        return Promise.resolve(this.cards);
    }

}